package com.wyl.tcp

import java.net.ServerSocket

/**
 * TCP通讯服务端ServerSocket实现
 */
fun main() {
    ServerSocket(9999).use { server ->
        server.accept().use { socket ->
            socket.getInputStream().use { ips ->
                println(String(ips.readBytes()))
            }
            socket.getOutputStream().use { ops ->
                ops.write("收到谢谢".toByteArray())
            }
//            val bytes = ByteArray(1024)
//            val len = it.getInputStream().read(bytes)
//            println(String(bytes,0,len))
        }
    }
}